const query = require("../db/query");

//客服上线薪增插入
const insertServerOnLine = (data) => {
    const sql = `INSERT INTO servers (uuid,sid,nick,ip,status) VALUES ('${data.uid}','${data.sid}','${data.nick}','${data.ip}','${data.status}');`;
    // console.log('保存新上线客服', data.uid, data.sid)
    return query(sql);
}

//客服离线修改
const updateServerStatus = (uuid, sid) => {
    const sql = `UPDATE servers SET status='0' WHERE uuid = '${uuid}' AND sid='${sid}' AND status =1;`;
    // console.log('客服离线更新完成', uuid, sid)
    return query(sql);
}

//查询在线客服
const queryOnLineSever = () => {
    const sql = `SELECT * FROM servers WHERE status = 1 ORDER BY servers.id DESC;`;
    let res_sql = query(sql);
    // console.log('查询在线客服',res_sql) //必须通过promise异步构造函数才能读取
    return res_sql
}






module.exports = {
    insertServerOnLine,
    updateServerStatus,
    queryOnLineSever,


}